package com.camelot.boot.module.system.api.aicompany;

import com.camelot.boot.framework.common.util.object.BeanUtils;
import com.camelot.boot.module.system.dal.dataobject.companyrequirement.CompanyRequirementDO;
import com.camelot.boot.module.system.service.companyrequirement.CompanyRequirementService;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

@Service
public class CompanyRequirementApiImpl implements CompanyRequirementApi {

    @Resource
    private CompanyRequirementService companyRequirementService;

    @Override
    public CompanyRequirementRespDTO getById(Long companyRequirementId) {
        CompanyRequirementDO companyRequirement = companyRequirementService.getCompanyRequirement(companyRequirementId);
        if (companyRequirement == null){
            return null;
        }
        return BeanUtils.toBean(companyRequirement, CompanyRequirementRespDTO.class);
    }

    @Override
    public List<CompanyRequirementRespDTO> listByIds(Collection<Long> ids) {
        if (CollectionUtils.isEmpty(ids)){
            return List.of();
        }

        List<CompanyRequirementDO> companyRequirementList = companyRequirementService.listByIds(ids);
        if (CollectionUtils.isEmpty(companyRequirementList)){
            return List.of();
        }
        return BeanUtils.toBean(companyRequirementList,CompanyRequirementRespDTO.class);
    }
}
